using System;
using System.ComponentModel;
using System.Globalization;

#region CustomObject3

[TypeConverter(typeof(CustomObject3Converter))]
public class CustomObject3
{
  private int _X;
  private int _Y;

  public int X
  {
    get { return _X; }
    set { _X = value; }
  }

  public int Y
  {
    get { return _Y; }
    set { _Y = value; }
  }

  public CustomObject3(int x, int y)
  {
    _X = x;
    _Y = y;
  }
} 

#endregion CustomObject3

#region CustomObject3Converter (TypeConverter)

public class CustomObject3Converter : TypeConverter
{
  public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
  {
    if (sourceType == typeof(String))
      return true;
    return base.CanConvertFrom(context, sourceType);
  }

  public override object ConvertFrom(ITypeDescriptorContext context,
    CultureInfo culture, object value)
  {
    if (value is String)
    {
      string[] values;
      
      values = ((string)value).Split(',');
      return new CustomObject3(int.Parse(values[0]), int.Parse(values[1]));
    }
    return base.ConvertFrom(context, culture, value);
  }

  public override object ConvertTo(ITypeDescriptorContext context,
     CultureInfo culture, object value, Type destinationType)
  {
    if (destinationType == typeof(String))
    {
      return ((CustomObject3)value).X + "," + ((CustomObject3)value).Y;
    }
    return base.ConvertTo(context, culture, value, destinationType);
  }
}

#endregion CustomObject3Converter (TypeConverter)